# -*- coding: UTF-8 -*-

from .BaseModel import BaseModel

class WechatGroupShareDataModel(BaseModel):

    _database = 'wechat'
    _table = 'wechat_group_share_data'

    SOURCE_TYPE_COMMON = 1  #公众号分享
    SOURCE_TYPE_MINIPROGRAM = 2 #小程序分享
    SOURCE_TYPE_QRCODE_SHARE = 3 #图片二维码


    def __init__(self, transport_core):
        self.super = super(WechatGroupShareDataModel, self)
        self.super.__init__(transport_core)


    def insert(self, insertDict):
        if not insertDict.has_key('gmt_create'):
            insertDict['gmt_create'] = int(self.core.loader.module('time').time())

        return self.super.insert(insertDict)


    def listByWhere(self, queryString, whereString, groupBy = '', orderBy = '', limit = ''):
        if groupBy:
            whereString += ' GROUP BY %s' % groupBy
        if orderBy:
            whereString += ' ORDER BY %s' % orderBy
        if limit:
            whereString += ' LIMIT %s' % limit

        return self.super.selectAll(queryString, whereString)
